/*
 * SharedAccount.java
 * 
 * Created on 19-jun-2007, 20:51:26
 * 
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.i2a.peacsy.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Tortuga
 */
@Entity
@Table(name = "TA_SHAR_SHARED_ACCOUNTS")
@NamedQueries({@NamedQuery(name = "SharedAccount.findByAccoCoCode", query = "SELECT s FROM SharedAccount s WHERE s.accoCoCode = :accoCoCode")})
public class SharedAccount implements Serializable {

  @Id
  @Column(name = "ACCO_CO_CODE", nullable = false)
  private Integer accoCoCode;

  @OneToMany(cascade = CascadeType.ALL, mappedBy = "sharCoCode")
  private Collection<WalletAccount> walletAccountCollection;
    protected static org.apache.commons.logging.Log
        log = org.apache.commons.logging.LogFactory.getLog(SharedAccount.class);

    public SharedAccount() {
    }

  public SharedAccount(Integer accoCoCode) {
    this.accoCoCode = accoCoCode;
  }

  public Integer getAccoCoCode() {
    return accoCoCode;
  }

  public void setAccoCoCode(Integer accoCoCode) {
    this.accoCoCode = accoCoCode;
  }

  public Collection<WalletAccount> getWalletAccountCollection() {
    return walletAccountCollection;
  }

  public void setWalletAccountCollection(Collection<WalletAccount> walletAccountCollection) {
    this.walletAccountCollection = walletAccountCollection;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (accoCoCode != null ? accoCoCode.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof SharedAccount)) {
      return false;
    }
    SharedAccount other = (SharedAccount) object;
    if (this.accoCoCode != other.accoCoCode && (this.accoCoCode == null || !this.accoCoCode.equals(other.accoCoCode))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "org.i2a.peacsy.entity.SharedAccount[accoCoCode=" + accoCoCode + "]";
  }

}
